{% extends "base.html" %}

{% block title %}{{post.title}}{% endblock %}
{% block content%}
        <div id="post">
            <div id="post-title">
            <a href="/blog/view?post_id={{post.id}}">{{post.title}}</a>
            
            <p class="sub-title"> {{post.created_time}} {{post.view}} views</p>
            </div>
           
            <div id="post-content">
            {{post.content|safe|linebreaks}}
            {%if user.is_staff%}
            <form action="/blog/del" method="post">
            {% csrf_token %}
            	<input type="hidden" value="{{post.id}}" name="post_id" />
                <input type="submit" value="delete" class="del-button" />
            </form>
            {%endif%}
            </div>
           
        </div>

    <div id="comments">
    	<div class="comment-header">Comment</div>
    	{%for comment in comment_list%}
        	
		<div class = "comment" id="comment{{comment.id}}">
	            
    			<p class="comment-by">
    				<span class="comment-author">{{comment.name}}</span> on <span class="comment-date">{{comment.date}}</span>
                    
    					
    			</p>
                <img src="/media/img/avatar/love-ava.png" alt="Avatar" class="comment-avatar"/>
    			<div class="comment-content">{{comment.content|linebreaks}}</div>
                
    		</div>
    	{%endfor%}
    </div>
    <div id = "new_comment">
    	<form action="" method="post">
        {% csrf_token %}
        	{{comment_form.name.label}}
            <div>{{comment_form.name}}</div>
            <span class="form-error">{{comment_form.name.errors}}</span>
        	{{comment_form.email.label}}
            <div>{{comment_form.email}}</div>
            <span class="form-error">{{comment_form.email.errors}}</span>
            {{comment_form.content.label}}
            <div>{{comment_form.content}}</div>
            <span class="form-error">{{comment_form.content.errors}}</span>        
            <input type="submit" value="Post Comment" class = "post-button"/>
         </form>
    </div>
    {%if user.is_staff%}
    <a href="blog/add"><span class="new-entry-button">New Entry</span></a>
    {%endif%}
    
 {% endblock %}
